Hi Don
Thanks for your answer.
I can’t check the ‘use target as pivot’ on the main camera as my camera animation use a different pivat than target. That’s why I tryed to check that box on my ‘temp’ camera before gathering camera info.
I didn’t find a way to get the target instead of pivot, so I did the math with distance / direction / position. Then it create a liste with all datas and build a csv.
I’ve done that script which works fine for what I need. It could be optimized I guess, I’m not so used to make script and code.
Sorry, I didn’t comment my script too.
# AUTHOR BILL
# VERSION 1.0.0
frames = lux.getAnimationInfo()["frames"]
cameras = lux.getCameras()
data = [
['camX','camY','camZ','twist','loatX','loatY','loatZ','frame']
]
values = [("folder", lux.DIALOG_FOLDER, "Output folder:", None),
("filename", lux.DIALOG_TEXT, "Csv filename (no extension)", lux.getCamera()),
("camera", lux.DIALOG_ITEM, "Camera to export", lux.getCamera() , cameras),
("start", lux.DIALOG_INTEGER, "Start frame:", 1, (1, frames)),
("end", lux.DIALOG_INTEGER, "End frame:", frames, (1, frames))]
opts = lux.getInputDialog(title = "Export Camera data",
desc = "Build a csv file with camera target, position & twist.",
values = values)
if len(opts["folder"]) == 0:
raise Exception("Folder cannot be empty!")
if len(opts["filename"]) == 0:
raise Exception("Filename cannot be empty!")
if start > end:
raise Exception("Start frame cannot be larger than end frame!")
fld = opts["folder"]
fname = opts["filename"]
start = opts["start"]-1
end = opts["end"]-1
csvpath = opts['folder'] + "/" + opts['filename'] + '.csv'
cam = opts['camera'][1]
def cameraInfo():
pos = lux.getCameraPosition()
twist = (lux.getSphericalCamera()[2],)
dire = lux.getCameraDirection()
dist = lux.getCameraDistance()
vect = luxmath.Vector(dire).mul(dist).val()
loat = luxmath.Vector(pos).add(vect).val()
frm = lux.getAnimationFrame()
return list (pos + twist + loat + (frm,))
def cameraBuild():
global data
lux.newCamera('temp')
data = list(data+[cameraInfo()])
lux.setCamera(cam)
lux.removeCamera('temp')
def main():
lux.setCamera(cam)
lux.setAnimationFrame(start)
while True :
currentframe = lux.getAnimationFrame()
if currentframe > end:
break
cameraBuild()
lux.setAnimationFrame(currentframe+1)
cameraInfo()
main()
import csv
with open(csvpath , 'w' , newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerows(data)